//SPDX-FileCopyrightText: Copyright 2025-2025 深圳市同心圆网络有限公司
//SPDX-License-Identifier: GPL-3.0-only

package ai_provider_api_serv

import (
	"context"

	"gitcode.com/eteam/api-server/dao/config_dao"
	"gitcode.com/eteam/proto-gen-go.git/ai_provider_api"
)

type AiProviderApiImpl struct {
	ai_provider_api.UnimplementedAiProviderApiServer
}

func (apiImpl *AiProviderApiImpl) ListLlmProvider(ctx context.Context, req *ai_provider_api.ListLlmProviderRequest) (*ai_provider_api.ListLlmProviderResponse, error) {
	providerItemList, err := config_dao.LlmProviderDao.List(ctx)
	if err != nil {
		return nil, err
	}
	providerList := []*ai_provider_api.LlmProviderInfo{}
	for _, providerItem := range providerItemList {
		providerList = append(providerList, providerItem.ToLlmProviderInfo())
	}
	return &ai_provider_api.ListLlmProviderResponse{
		Code:         ai_provider_api.ListLlmProviderResponse_CODE_OK,
		ProviderList: providerList,
	}, nil
}
